<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <!-- vue DOM更新时异步的
    
        vm.$nextTick  数据更新dom更新完毕之后执行的回调

        Vue.nextTick
    -->
    <div id="app">
        <div ref="msgDiv">{{msg}}</div>
        <div v-if="msg1">msg1:{{msg1}}</div>
        <div v-if="msg2">msg2:{{msg2}}</div>
        <div v-if="msg3">msg3:{{msg3}}</div>
        <button @click="changeMsg">change msg</button>
    </div>
    <script src="./vue.js"></script>
    <script>
        let vm = new Vue({
            el:'#app',
            data:{
                msg:'hello vue',
                msg1:'',
                msg2:'',
                msg3:''
            },
            methods: {
                changeMsg(){
                    this.msg = 'hello world';
                    this.msg1 = this.$refs.msgDiv.innerHTML; //hello vue
                    this.$nextTick().then(() => {
                        this.msg2 = this.$refs.msgDiv.innerHTML; //hello world
                    })
                    this.msg3 = this.$refs.msgDiv.innerHTML;  //hello vue
                }
            },
        })
    </script>
</body>
</html>